package com.cctv.haierstore.search.controller;

import com.cctv.haierstore.search.service.EsearchService;
import com.cctv.haierstore.search.vo.SearchParamVo;
import com.cctv.haierstore.search.vo.SearchResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author huayi
 * @date 2023年12月23日 13:59
 */
@Controller
public class SearchController {

    @Autowired
    EsearchService searchService;

    @GetMapping(value = {"/","/list.html"})
    public String ListPage(SearchParamVo searchParamVo, Model model,HttpServletRequest request){
        String queryString = request.getQueryString();
        searchParamVo.set_queryString(queryString);
        SearchResultVo result = searchService.search(searchParamVo);
        model.addAttribute("result", result);
        return "list";
    }
}

